<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north'" class="center" style="">
        <div class="webmap">
            <p class="webmaptip">当前位置:</p>
            <a href="javascript:;" class="easyui-link" data-options="plain:true">财务管理</a>
            <p class="webmaptip">></p>
            <a href="javascript:;" class="easyui-link" data-options="plain:true">投资流水</a>
        </div>
        <div class="querybycon">
            <form id="query">
                <div class="queryinfo">
                    <div>交易单号<input type="text" name="trdNo"></div>
                    <div>用户名<input type="text" name="telephone"></div>
                    <div>投标方式 <input class="easyui-combobox" name="trdType"
                                     data-options="url:'/dictionary/chanel?all=true'"></div>
                    <div>借款编号<input type="text" name="targetNo"></div>
                    <div style="width: 470px;">
                        投资时间 <input name="beginTime" class="easyui-datetimebox"> - <input name="endTime"
                                                                                          class="easyui-datetimebox">
                    </div>
                    <div class="query"><a id="querybtn" href="javascript:;" class="easyui-linkbutton"
                                          data-options="iconCls:'fa fa-search'"></a>
                    </div>
                </div>

            </form>
        </div>
        <div class="querybtn">

            <a id="exportbtn" href="javascript:;" class="easyui-linkbutton"
               data-options="iconCls:'fa fa-save'">导出</a>
        </div>
        <div class="separator"></div>
    </div>
    <div data-options="region:'center'" class="center">
        <table id="list"></table>
    </div>
</div>

<script type="text/javascript">

    var listUrl = "/investFlowDetail/list";
    var exportUrl = "/investFlowDetail/export";

    var columns = [[{
        field: 'id',
        checkbox: true
    }, {
        field: 'trdNo',
        title: '交易单号',
    }, {
        field: 'contractNo',
        title: '借款编号',
    }, {
        field: 'telephone',
        title: '用户名',
    }, {
        field: 'name',
        title: '姓名'
    }, {
        field: 'platform',
        title: '投标来源',
        formatter: function (value, row, index) {
            return dic["chanel"][value];
        }
    }, {
        field: 'amount',
        title: '投资金额(元)', formatter: function (value) {
            return formatNumber(value, 2);
        }
    }, {
        field: 'bonusType',
        title: '优惠券类型',
        formatter: function (value, row, index) {
            if (value == null) {
                return "";
            }
            return dic["userBonusType"][value];
        }
    }, {
        field: 'bonusValue',
        title: '面值或利率',
        formatter: function (value, row, index) {
            if (value == null) {
                return "";
            } else {
                if (null != row["bonusType"] && row["bonusType"] == 2) {
                    return value * 100 + "%"
                } else {
                    return value
                }
            }
        }
    }, {
        field: 'actualAmount',
        title: '实际支付金额(元)', formatter: function (value) {
            return formatNumber(value, 2);
        }
    }, {
        field: 'expecInterest',
        title: '预期年化收益率',
        formatter: function (value, row, index) {
            if (value == null) {
                return "";
            } else {
                if (null != row["bonusType"] && row["bonusType"] == 2) {
                    return row["expecInterest"] + "%+" + row["bonusValue"] * 100 + "%"
                } else {
                    return row["expecInterest"] + "%"
                }
            }
        }
    }, {
        field: 'finishTime',
        title: '投资时间'
    }]];
    list.init({url: listUrl, columns: columns});
    $("#exportbtn").click(function () {
        var obj = $("#query").serializeObject();
        window.open(exportUrl + "?" + $(obj).formatJson2Url());
    });
    function formatNumber(value, fixed) {
        var number = Number(value);
        if (isNaN(number)) {
            return '';
        } else {
            return number.toFixed(2);
        }
    }
</script>
